applied JPEG loader fix from maemo. this fix makes sure stop_load()
authorTim Janik <timj@imendio.com>
Wed, 28 Mar 2007 13:29:17 +0000 (13:29 +0000)
committerTim Janik <timj@src.gnome.org>
Wed, 28 Mar 2007 13:29:17 +0000 (13:29 +0000)
Wed Mar 28 15:27:35 2007  Tim Janik  <timj@imendio.com>

        * io-jpeg.c: applied JPEG loader fix from maemo. this fix makes sure
        stop_load() doesn't forget about its return value, and it pulls the
        check for infinite looping out of an else branch in load_increment()
        so it runs unconditionally, fixes #397643.

svn path=/trunk/; revision=17567

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-jpeg.c

index eb3cbaa70ec0a05dd06a39242456f106606976d9..2b853f6cf28d29d4244a5a65e4909f789870546b 100644 (file)
@@ -1,3 +1,10 @@
+Wed Mar 28 15:27:35 2007  Tim Janik  <timj@imendio.com>
+
+       * io-jpeg.c: applied JPEG loader fix from maemo. this fix makes sure
+       stop_load() doesn't forget about its return value, and it pulls the
+       check for infinite looping out of an else branch in load_increment()
+       so it runs unconditionally, fixes #397643.
+
 2007-03-08  Matthias Clasen <mclasen@redhat.com>
 
        * gdk-pixbuf-scaled-anim.[hc]: Implement an animation
index cd11ebc9cfe141dd2eb73056c22a2b96a4b26b2a..462a99d1df224a7331bc4d218c2a5179f1e3d902 100644 (file)
@@ -518,6 +518,7 @@ static gboolean
 gdk_pixbuf__jpeg_image_stop_load (gpointer data, GError **error)
 {
        JpegProgContext *context = (JpegProgContext *) data;
+        gboolean retval;
 
        g_return_val_if_fail (context != NULL, TRUE);
        
@@ -530,12 +531,14 @@ gdk_pixbuf__jpeg_image_stop_load (gpointer data, GError **error)
        
        /* if we have an error? */
        if (sigsetjmp (context->jerr.setjmp_buffer, 1)) {
-               jpeg_destroy_decompress (&context->cinfo);
+                retval = FALSE;
        } else {
-               jpeg_finish_decompress(&context->cinfo);
-               jpeg_destroy_decompress(&context->cinfo);
+               jpeg_finish_decompress (&context->cinfo);
+                retval = TRUE;
        }
 
+        jpeg_destroy_decompress (&context->cinfo);
+
        if (context->cinfo.src) {
                my_src_ptr src = (my_src_ptr) context->cinfo.src;
                
@@ -544,7 +547,7 @@ gdk_pixbuf__jpeg_image_stop_load (gpointer data, GError **error)
 
        g_free (context);
 
-        return TRUE;
+        return retval;
 }
 
 
@@ -686,17 +689,17 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
                        src->pub.bytes_in_buffer += num_copy;
                        bufhd += num_copy;
                        num_left -= num_copy;
-               } else {
-               /* did anything change from last pass, if not return */
-                       if (first) {
-                               last_bytes_left = src->pub.bytes_in_buffer;
-                               first = FALSE;
-                       } else if (src->pub.bytes_in_buffer == last_bytes_left)
-                               spinguard++;
-                       else
-                               last_bytes_left = src->pub.bytes_in_buffer;
                }
 
+                /* did anything change from last pass, if not return */
+                if (first) {
+                        last_bytes_left = src->pub.bytes_in_buffer;
+                        first = FALSE;
+                } else if (src->pub.bytes_in_buffer == last_bytes_left)
+                        spinguard++;
+                else
+                        last_bytes_left = src->pub.bytes_in_buffer;
+
                /* should not go through twice and not pull bytes out of buf */
                if (spinguard > 2)
                        return TRUE;